From ff40c3bfa3a7c3a00c55554f6c64e6cd793850dd Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 6 May 2005 17:45:30 +0000 Subject: [PATCH] Add 'maxcount' argument to radius filter to allow user to limit number of points to be passed downstream. (Specifically to stop Magellan's Geocache Manager from hurting itself.) --- gpsbabel/position.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gpsbabel/position.c b/gpsbabel/position.c index 49a79929b..2df410826 100644 --- a/gpsbabel/position.c +++ b/gpsbabel/position.c @@ -35,6 +35,8 @@ static char *latopt = NULL; static char *lonopt = NULL; static char *exclopt = NULL; static char *nosort = NULL; +static char *maxctarg = NULL; +static int maxct; waypoint * home_pos; @@ -64,6 +66,8 @@ arglist_t radius_args[] = { NULL, ARGTYPE_BOOL }, {"nosort", &nosort, "Inhibit sort by distance to center.", NULL, ARGTYPE_BOOL }, + {"maxcount", &maxctarg,"Output no more than this number of points", + NULL, ARGTYPE_INT }, {0, 0, 0, 0, 0} }; @@ -325,9 +329,14 @@ radius_process(void) */ for (i = 0; i < wc; i++) { waypoint * wp = comp[i]; - waypt_add(wp); + xfree(wp->extra_data); wp->extra_data = NULL; + + if (maxctarg && i >= maxct) { + continue; + } + waypt_add(wp); } xfree(comp); @@ -348,6 +357,12 @@ radius_init(const char *args) { } } + if (maxctarg) { + maxct = atoi(maxctarg); + } else { + maxct = 0; + } + home_pos = (waypoint *) xcalloc(sizeof(*home_pos), 1); if (latopt) -- 2.30.2